package org.keyroy.map_editor.map.m;

import org.keyroy.tag.Tag;
import org.keyroy.tag.XmlSupport;

public class Point implements XmlSupport {
	public int x;
	public int y;

	public Point() {
	}

	public Point(int x, int y) {
		set(x, y);
	}

	public void setLocation(Point point) {
		this.x = point.x;
		this.y = point.y;
	}

	public void setLocation(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public final void set(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public void moveTo(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public void move(int ox, int oy) {
		x += ox;
		y += oy;
	}

	@Override
	public String getTagName() {
		return "p";
	}

	@Override
	public void initObj(Tag tag) {
		x = tag.getParameterIntValue("x");
		y = tag.getParameterIntValue("y");
	}

	@Override
	public void initTag(Tag tag) {
		tag.addParameter("x", x, x != 0);
		tag.addParameter("y", y, y != 0);
	}

	@Override
	public String toString() {
		return "[" + x + "," + y + "]";
	}
}
